<%-------------------------------------------------------------------
 * 页面名称：myAccountDetail.jsp
 * 功能描述：新增银行账户
 * Action: cn.agiledata.bank.myspace.action.AccountAction
 *
 *-------------------------------------------------------------------
--%>

<%
	String path = request.getContextPath();
	request.setAttribute("modify", request.getParameter("modifyType"));
	String type = request.getParameter("modifyType");

	Long id = new Long(WeatherUtil.getAccountIdFromSession(request));

	HibernateAccountDAO hd = null;
	try {
		hd = (HibernateAccountDAO) IPBAppFactory.getObj("accountDAO");
	} catch (Exception e) {
		e.printStackTrace();
	}
	Account user = hd.getAccountById(id);

	boolean flag = false;
	if (user.getName() == null
			|| (user.getName() != null && user.getName().length() == 0)) {
		flag = true;
	}
%>
<%@ page contentType="text/html; charset=utf-8"%>
<%@ taglib uri="/WEB-INF/conf/tld/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/conf/tld/struts-tiles.tld" prefix="tiles"%>
<%@ taglib uri="/WEB-INF/conf/tld/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/conf/tld/struts-bean.tld" prefix="bean"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="ipb" uri="/WEB-INF/conf/tld/ipb.tld"%>
<%@ taglib prefix="ad" uri="agiledata"%>
<%@ page
	import="cn.agiledata.bank.common.util.WeatherUtil,cn.agiledata.bank.account.dao.hibernate.HibernateAccountDAO,com.vnv.infrastructure.logic.IPBAppFactory,cn.agiledata.bank.hibernateBean.Account,cn.agiledata.bank.common.util.Constant"%>
<script type='text/javascript' src='<%=path%>/js/ufront.js'></script>
<script type='text/javascript'
	src='<%=path%>/dwr/interface/AccountLogic.js'></script>
<script type='text/javascript' src='<%=path%>/js/ufront.js'></script>
<script language="javascript" type="text/javascript"
	src="<%=path%>/js/choiceCity.js"></script>
<script type='text/javascript'
	src='<%=path%>/dwr/interface/accountTemplate.js'></script>
<SCRIPT LANGUAGE="JavaScript">
	function update() {
		AccountLogic.getCityList(createList, $("provSeq").value);
	}
	function createList(data) {
  		DWRUtil.removeAllOptions("citySeq");
  		DWRUtil.addOptions("citySeq", data,'cityId','cityName');
	}
	function submitProcess() {
		var formName = document.forms["0"];
		if (checkNecessaryInput(formName) && checkInputMaxlength(formName)) {
			if (formName.accountId.value.length>5 && formName.accountId.value.length<33) {
				if (document.getElementById("accountName")!=null && document.getElementById("accountNameSpan")!=null) { 
					document.getElementById("accountName").value = document.getElementById("accountNameSpan").innerText;
				}
				formName.submit();
			} else {
				alert("有效号码的长度应该在6位到32位之间！");
			}
		}
	}
	function id_keyup(txtinput) {
		txtinput.value=txtinput.value.replace(/(^\s*)|(\s*$)/g, "");
	}		
</SCRIPT>

<%
boolean isNew = true;
%>
<logic:notEmpty name="MyAccountBankForm" property="id">
	<%
	isNew = false;
	%>
</logic:notEmpty>

<div id="main">

	<div class="content_right">
		<div style="width:745px;margin-left:10px;">
			<div class="titleinfo">
				<%=isNew ? "新增" : "修改"%>
				银行账户
			</div>
			<div class="edit_pass">
				<table width="100%" border="0" align="center" cellpadding="5"
					cellspacing="0">
					<html:form action="accountSubmit">
						<html:hidden property="id" />
						<tr>
							<!-- 账户名 -->
							<td width="23%" align="right" valign="top" height="27">
								<span class="orang12b">*</span> 账户名：
							</td>
							<td width="77%" height="27">
								<%
								if ("A".equals(user.getAccountType())) {
								%>
								<logic:present name="aBank">
									<logic:notEmpty name="aBank" property="accountName">
										<logic:equal name="idcardStatus"
											value="<%=Constant.AUTHENTICATION_STATUS_PASS%>">
											<!-- 通过 -->
											<bean:write name="aBank" property="accountName" />
											<html:hidden name="aBank" property="accountName" />
										</logic:equal>
										<logic:notEqual name="idcardStatus"
											value="<%=Constant.AUTHENTICATION_STATUS_PASS%>">
											<!-- 未通过 -->
											<html:text name="aBank" property="accountName"
												onblur="killSpace(this)" alt="用户名" size="30" maxlength="64" />
											<span class="font_gray"><br /> 银行账户（银行卡）持有人的真实姓名 </span>
										</logic:notEqual>
									</logic:notEmpty>
								</logic:present>
								<logic:notPresent name="aBank">
									<logic:equal name="idcardStatus"
										value="<%=Constant.AUTHENTICATION_STATUS_PASS%>">
										<!-- 通过 -->
										<span id="accountNameSpan"><%=user.getName()%> </span>
										<input name="accountName" type="hidden">
									</logic:equal>
									<logic:notEqual name="idcardStatus"
										value="<%=Constant.AUTHENTICATION_STATUS_PASS%>">
										<!-- 未通过 -->
										<input name="accountName" type="text" onblur="killSpace(this)"
											alt="用户名" size="30" maxlength="64">
										<span class="font_gray"><br /> 银行账户（银行卡）持有人的真实姓名 </span>
							</td>
							</logic:notEqual>
							</logic:notPresent>
							<%
							} else if ("B".equals(user.getAccountType())) {
							%>
							<span id="accountNameSpan"><%=user.getName()%> </span>
							<input name="accountName" type="hidden">
							<%
							}
							%>
						</tr>
						<!-- 类　型 -->
						<tr>
							<td align="right" height="27">
								<span class="orang12b">* </span>类 型：
								<br />
							</td>
							<td height="27">
								<div class="select">
									<div>
										<html:select property="cardType" alt="类型">
											<ad:agileOptions typeid="CARD_TYPE" dummyLabel="请选择" />
										</html:select>
									</div>
								</div>
							</td>
						</tr>
						<!-- 所属银行 -->
						<tr>
							<td align="right" height="27">
								<span class="orang12b">* </span>所属银行：
								<br />
							</td>
							<td height="27">
								<div class="select">
									<div>
										<html:select property="bankInfoId" alt="所属银行">
											<%
											if ("A".equals(user.getAccountType())) {
											%>
											<ad:agileOptions typeid="BANK_INFO" dummyLabel="请选择" />
											<%
											} else if ("B".equals(user.getAccountType())) {
											%>
											<ad:agileOptions typeid="ENTERPRISE_BANK_INFO"
												dummyLabel="请选择" />
											<%
											}
											%>
										</html:select>
									</div>
								</div>
							</td>
						</tr>
						<!-- 账户别名 -->
						<tr>
							<td align="right" valign="top" height="27">
								<span class="orang12b">* </span>
								<bean:write name="displayBean" property="FAccountType" />
								：
							</td>
							<td height="27">
								<html:text property="bankAlias"
									alt="${displayBean.FAccountType}" maxlength="45" size="30"
									styleClass="inputStyle" onblur="killAllSpace(this)" />
								<span class="font_gray"><br />
									为用户自定义，方便您管理（最长为15个汉字或45个字母）</span>
							</td>
						</tr>
						<!-- 银行账号/银行卡号 -->
						<tr>
							<td align="right" valign="top" height="27">
								<span class="orang12b">* </span>
								<bean:write name="displayBean" property="FAccountName" />
								：
							</td>
							<td height="27">
								<%
								if (isNew) {
								%>
								<html:text property="accountId"
									alt="${displayBean.FAccountName}" maxlength="32" size="30"
									styleClass="inputStyle" onblur="bankCardValidate(this);" />
								<%
								} else {
								%>
								<html:text property="accountId" alt="银行卡号码" maxlength="32"
									size="30" styleClass="inputStyle" readonly="true" />
								<%
								}
								%>
								<br />
								<!-- 特别提醒 -->
							<table width="100%" border="0" align="center" cellpadding="7"
										cellspacing="1" bgcolor="#f9e277" style="margin:10px 0;">
										<tr>
											<td bgcolor="#fffdf5">
												<table width="100%" border="0" cellpadding="3"
													cellspacing="0">
													<tr>
														<td width="3%" height="25" valign="top"
															style="border-bottom:1px solid #ccc;"></td>
														<td width="97%" align="left" class="red12b"
															style="border-bottom:1px solid #ccc;">
															特别提醒
														</td>
													</tr>
												<tr>
													<td valign="top">
														&nbsp;
													</td>
													<td align="left" class="font_gray">
														<span class="text9green"> 银行账号/银行卡号为数字，且长度应该在 <span
															class="redColor12px">6</span>位到 <span
															class="redColor12px">32</span>位之间！</span>
													</td>
												</tr>
												<tr>
													<td valign="top">
														&nbsp;
													</td>
													<td align="left" class="font_gray">
														<span class="text9green">存折账号的 <span
															class="redColor12px">'*'</span>和 企业账户的 <span
															class="redColor12px">'-'</span>在此均 <span
															class="redColor12px">无需输入</span>
														</span>
													</td>
												</tr>
											</table>
										</td>
									</tr>
								</table>
							</td>
						</tr>
						<!-- 开户行省份 -->
						<tr>
							<td align="right" height="27">
								<span class="orang12b">*</span> 开户行省份：
							</td>
							<td bgcolor="#FFFFFF" height="27">
								<div class="select">
									<div>
										<html:select property="provSeq" onchange="update()" styleId="provSeq"
											alt="开户行省份">
											<html:options collection="province" property="cityId"
												labelProperty="cityName" />
										</html:select>
									</div>
								</div>
							</td>
						</tr>
						<!-- 开户行城市 -->
						<tr>
							<td align="right" height="27">
								<span class="orang12b">*</span> 开户行城市：
							</td>
							<td bgcolor="#FFFFFF" height="27">
								<div class="select">
									<div>
										<html:select property="citySeq" alt="开户行城市" styleId="citySeq">
											<html:options collection="city" property="cityId"
												labelProperty="cityName" />
										</html:select>
									</div>
								</div>
							</td>
						</tr>
						<!--开户银行名称-->
						<tr>
							<td align="right" valign="top" height="27">
								<span class="orang12b">*</span> 开户银行名称：
							</td>
							<td height="27">
								<html:text property="bankName" alt="开户银行名称" maxlength="255"
									size="45" styleClass="inputStyle" onblur="killSpace(this)" />
								<br />
						<table width="100%" border="0" align="center" cellpadding="7"
										cellspacing="1" bgcolor="#f9e277" style="margin:10px 0;">
										<tr>
											<td bgcolor="#fffdf5">
												<table width="100%" border="0" cellpadding="3"
													cellspacing="0">
													<tr>
														<td width="3%" height="25" valign="top"
															style="border-bottom:1px solid #ccc;"></td>
														<td width="97%" align="left" class="red12b"
															style="border-bottom:1px solid #ccc;">
															特别提醒
														</td>
													</tr>
												<tr>
													<td valign="top">
														&nbsp;
													</td>
													<td align="left" class="font_gray">
														<span class="text9green"> 务必正确填写您的
														银行卡开户行名称！如果您不填写或者填写不正确，将会导致账户内的资金无法正常汇入您的银行卡内！</span>
													</td>
												</tr>
												<tr>
													<td valign="top">
														&nbsp;
													</td>
													<td align="left" class="font_gray">
														<span class="text9green"> </span><span
															class="redColor12px">此处无需重复填写银行名称与省市，只需填写具体名称。</span><span
															class="text9green">如：海淀支行海体分理处。</span>
													</td>
												</tr>
												<tr>
													<td valign="top">
														&nbsp;
													</td>
													<td align="left" class="font_gray">
														<span class="text9green"> 如果您无法确定您的
														银行卡的开户名称，您可以致电相关银行客服，报出您的卡号，即可获得开户行信息。</span>
													</td>
												</tr>
											</table>

										</td>
									</tr>
								</table>
					</html:form>
					</td>
					</tr>
					<tr>
						<td align="right" valign="top">
							&nbsp;
						</td>
						<td>

							<span class="button_Frame"> <input type="button"
									name="sure" value="确 定" class="button_style"
									onclick="submitProcess();" />
								<input type="button" name="return" value="返 回"
									class="button_style" onclick="location.href='accountList.do';" />
							</span>
						</td>
					</tr>
				</table>
			</div>
		</div>
	</div>
</div>
</div>


